import requests
import re

id = 1
username = 'test01'
password = '123456'
vericode = 'shtd'

# 首页
# 首页验证码
# 登录
url_first = r'http://172.16.22.108:8080/bsams/front/login.do'
url_vericode = r'http://172.16.22.108:8080/bsams/front/vericode.do'

data = {
    'taskId': id,
    'loginName': username,
    'password': password,
    'vericode': vericode
}
s = requests.Session()
s.get(url_first)
s.get(url_vericode)
# 登录
resp = s.post(url_first, data=data)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 资产查询
url_info = r'http://172.16.22.108:8080/bsams/front/asset/asset_list.do'
resp = s.post(url_info)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
#资产新增   无参
url_add = r'http://172.16.22.108:8080/bsams/front/asset/asset_new.do'
resp = s.get(url_add)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
#资产新增   有参
url_add = r'http://172.16.22.108:8080/bsams/front/asset/asset_new.do'
title = '电脑电脑'
storageId = '辽宁异界公司'
providerId = '电脑设备库'
data = {
    'title': title,
    'storageId': storageId,
    'providerId': providerId
}
resp = s.post(url_add,data=data)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)

# 资产修改
# url_mod = r'http://172.16.22.108:8080/bsams/front/asset/asset_update.do'
# asset_id = {'id': '1745'}
# s.get(url_mod, params=asset_id)
# mod_title = {
#     'title': '遥遥领先',
#     'storageId': '维信科技发展有限公司',
#     'providerId': '总经理办公室'
# }
# resp = s.post(url_mod, data=mod_title)
# patt = r'<title>(.*?)</title>'
# title = re.findall(patt, resp.text)
# print(title)

# 资产借用页
url_lend_page = r'http://172.16.22.108:8080/bsams/front/asset/asset_borrow.do'
asset_id = {'id': '1636'}
resp = s.get(url_lend_page,params=asset_id)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 资产借用
url_lend = r'http://172.16.22.108:8080/bsams/front/asset/asset_borrow_save.do'
lend_id = {
    'id': '1636',
    'departId': '软件部',
    'remark': '1',
}
resp = s.post(url_lend_page,data=lend_id)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 资产归还页
url_return_page = r'http://172.16.22.108:8080/bsams/front/asset/asset_giveBack.do'
asset_id = {'id': '1686'}
resp = s.get(url_return_page,params=asset_id)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 资产归还
url_return = r'http://172.16.22.108:8080/bsams/front/asset/asset_giveBack_save.do'
asset_id = {'id': '1686'}
resp = s.post(url_return,data=asset_id)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 查询存放地点
url_deposit = r'http://172.16.22.108:8080/bsams/front/asset_storage/asset_storage_list.do'
resp = s.post(url_deposit)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)

# 查询存供应商
url_supplier = r'http://172.16.22.108:8080/bsams/front/asset_provider/asset_provider_list.do'
resp = s.post(url_supplier)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)
# 个人信息页
url_information = r'http://172.16.22.108:8080/bsams/front/asset_user/user_info.do'
resp = s.get(url_information)
patt = r'<title>(.*?)</title>'
title = re.findall(patt, resp.text)
print(title)

# 修改手机号
url_phone = r'http://172.16.22.108:8080/bsams/front/asset_user/update_phone.do'
asset_id = {'assetUserId': '2','phone':'152093845'}
resp = s.post(url_phone,data=asset_id)
print(resp.text)